package com.ssy.lingxi.product.serviceImpl.saleorder.invoicestype;

import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.model.request.warehouse.InvoicesAddRequest;
import com.ssy.lingxi.product.api.model.request.warehouse.InvoicesUpdataRequest;
import com.ssy.lingxi.product.entity.warehouse.Invoices;
import com.ssy.lingxi.product.service.saleorder.invoicestype.InvoicesTypeStrategy;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 销售发货单业务处理
 *
 * @author wrc
 * @date 2020/12/21
 */
@Service("saleInvoices")
public class SaleOrderImpl implements InvoicesTypeStrategy {

    /**
     * 添加单据-销售发货单业务处理
     */
    @Override
    public Wrapper invoicesAdd(Invoices invoices, InvoicesAddRequest request, UserLoginCacheDTO sysUser) {
        return null;
    }

    /**
     * 修改单据-销售发货单业务处理
     */
    @Override
    public Wrapper invoicesUpdata(Invoices invoices, InvoicesUpdataRequest request) {
//        List<InvoicesParticularsRequest> collect = request.getInvoicesDetailsRequests().stream().map(invoicesDetailsRequest -> {
//            InvoicesParticularsRequest invoicesParticularsRequest = new InvoicesParticularsRequest();
//            BeanUtils.copyProperties(invoicesDetailsRequest, invoicesParticularsRequest);
//            return invoicesParticularsRequest;
//        }).collect(Collectors.toList());
//        com.ssy.lingxi.order.api.dto.request.InvoicesDetailsRequest invoicesDetailsRequest = new com.ssy.lingxi.order.api.dto.request.InvoicesDetailsRequest();
//        invoicesDetailsRequest.setId(invoices.getId());
//        invoicesDetailsRequest.setInvoicesNo(invoices.getInvoicesNo());
//        invoicesDetailsRequest.setOrderNo(invoices.getOrderNo());
//        invoicesDetailsRequest.setRelevanceInvoicesId(invoices.getRelevanceInvoicesId());
//        invoicesDetailsRequest.setInvoicesDetailsList(collect);
//        invoicesDetailsRequest.setInvoicesTypeId(invoices.getInvoicesTypeId());
//        return purchaseOrderControllerFeign.deliveryDetailsUpdate(invoicesDetailsRequest);
        return Wrapper.success();
    }

    /**
     * 批量审核单据
     *
     * @author wrc
     * @date 2020/12/29
     */
    @Override
    public Wrapper invoicesReviewAll(List<Invoices> invoicess, UserLoginCacheDTO sysUser) {
        return Wrapper.success();
//        for (Invoices invoices : invoicess) {
//            AuditSalesInvoiceRequest auditSalesInvoiceRequest = new AuditSalesInvoiceRequest();
//            auditSalesInvoiceRequest.setDeliveryType(invoices.getDeliveryType());
//            auditSalesInvoiceRequest.setId(invoices.getId());
//            auditSalesInvoiceRequest.setOrderId(invoices.getRelevanceInvoicesId());
//            auditSalesInvoiceRequest.setUserJobTitle(sysUser.getUserJobTitle());
//            auditSalesInvoiceRequest.setUserName(sysUser.getUserName());
//            auditSalesInvoiceRequest.setUserOrgName(sysUser.getUserOrgName());
//            auditSalesInvoiceRequest.setInvoicesNo(invoices.getInvoicesNo());
//            auditSalesInvoiceRequest.setSysUser(sysUser);
//            //销售发货单审核通知
//            Wrapper wrapper = purchaseOrderControllerFeign.feignAuditSalesInvoice(auditSalesInvoiceRequest);
//            if (ResponseCode.SUCCESS.getCode() != wrapper.getCode()) {
//                return wrapper;
//            }
//        }
//        return Wrapper.success();
    }
}
